package com.safe.ele.util;

import java.util.Random;

/**
 * @program: StartCoding
 * @description:
 * @author: Feri(邢朋辉)
 * @create: 2021-01-06 14:33
 */
public class NumRandomUtil {
    /**
     * 随机生成指定位数的数字
     * @param len 长度*/
    public static int createRandomNum(int len){
        Random random=new Random();
        //len=4 1000-9999  1000+(0-8999) 9000=10000-1000
        //len=6 100000-999999 100000+(0-899999)
        //0-界限
        return (int)(random.nextInt((int)(Math.pow(10,len)-Math.pow(10,len-1)))+
                Math.pow(10,len-1));
    }
}
